package Crawler_data;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import each_class.RanKingClass;

public class LoadData {

	public static Map<String, List<RanKingClass>> home_playlist() {
		// 飙升榜//新歌榜//原创榜//热歌榜
		Map<String, List<RanKingClass>> map = new LinkedHashMap<String, List<RanKingClass>>();
		List<RanKingClass> list1 = new ArrayList<RanKingClass>();
		List<RanKingClass> list2 = new ArrayList<RanKingClass>();

		String[] s = { "19723756", "3779629", "2884035", "3778678" };
		String[] s1 = { "4935954952", "2803600679", "4942422983", "2541774293", "2737604083", "2167971380", "5382366823",
				"5281964966", "6789244444", "5088639803", "2829779628", "2799091270", "2866624523", "2177013824",
				"5380303614", "2550277551", "3236134881", "3455816", "702998357", "367468866", "5327906368",
				"6731059383", "2987193702", "4968224656", "5459043157", "5002203969", "6651601935", "508966781",
				"6731043850" };
		int t = 0;
		int[] ts = new int[4];
		for (int i = 0; i < 4; i++) {
			boolean is = true;
			while (is) {
				t = (int) (Math.random() * 28);
				for (int j = 0; j < ts.length; j++) {
					if (ts[j] == t) {
						break;
					}
					if (j == 3) {
						is = false;
					}
				}
			}
			ts[i] = t;
			
		}

		for (int i = 0; i < 4; i++) {
			RanKingClass ranKingClass = Crawler_data.ranKing(s[i]);
			RanKingClass ranKingClass1 = Crawler_data.ranKing(s1[ts[i]]);

			int f = 0;

			while (ranKingClass.getRanKingClass_name() == null && f++<2) {
				ranKingClass = Crawler_data.ranKing(s[i]);
			}
			//System.out.println(f+"jjjjjj");			
			f = 0;

			while (ranKingClass1.getRanKingClass_name() == null && f<2) {
				f++;
				ranKingClass1 = Crawler_data.ranKing(s1[ts[i]]);

			}
			//System.out.println(f);		
			list1.add(ranKingClass);
			list2.add(ranKingClass1);
		}

		//System.out.println(list1);
		map.put("官方歌单", list1);
		map.put("推荐歌单", list2);

		return map;
	}

}
